<template>
  <div>
    <mt-swipe :auto="4000">
      <mt-swipe-item v-for="ord in ordertable" :key="ord.o_id">
        <div class="mui-input-row">
          <label>订单编号:</label>
          <span class="span">{{ ord.o_serial }}</span>
        </div>
        <div class="mui-input-row">
          <label>商品价格:</label>
          <span class="span">{{ ord.o_money  | numFilter }}万</span>
        </div>
        <div class="mui-input-row">
          <label>下单时间:</label>
          <span class="span">{{ ord.o_date | dateFmt("YYYY-MM-DD") }}</span>
        </div>
        <div class="mui-input-row">
          <label>下单地址:</label>
          <span class="span">{{ ord.o_address }}</span>
        </div>
        <div class="mui-input-row">
          <label>商品备注:</label>
          <span class="span">{{ ord.o_comment }}</span>
        </div>
        <div class="mui-input-row">
          <label>订单状态:</label>
          <span class="span">{{ ord.o_status }}</span>      	        
        </div>
		        <button type="button" v-show="ord.o_status=='发货中'" @click="but(ord.o_id)"  class="mui-btn mui-btn-primary mui-btn-block mui-btn-outlined">确定收货</button>
      </mt-swipe-item>
    </mt-swipe>
  </div>
</template>
  
<script async>
import moment from "moment";
export default {
  filters: {
    dateFmt: function (str, pattern) {
      return moment(str).format("YYYY-MM-DD HH:mm:ss");
    },
     numFilter (value) {
    // 截取当前数据到小数点后两位
    let realVal = parseFloat(value).toFixed(2)
    return realVal
     }
  },
  data() {
    return {
      uid: this.$route.params.uid,
      ordertable: [],
      imgurl: "http://localhost:3000/images/car/",
    };
  },
  methods: {
    getordertable() {
      this.$ajax({
        url: "before/ordertable/" + this.uid,
        method: "get",
      }).then((resp) => {
       this.ordertable = resp.data.message;
      });
    },
    but(o_id){
      let person={
          "o_status":3,
          "o_id":o_id
        }
		     this.$ajax({
			   url:'before/ordertables',
			   method:'put',
			   data:person
		   }).then(resp=>{
         this.getordertable()
		   })       
    },
   
  },
  created() {
     let uid=JSON.parse(localStorage.getItem("uid")) 
     this.uid=uid
    this.getordertable();
  },
};
</script>

<style scoped>
.mint-swipe {
  height: 700px;
  background:linear-gradient(to right,pink,white,pink)

}
.span {
  margin-top: 10px;
  display: block;
}
</style>